#if 0
#ifndef circle_buffer_h
#define circle_buffer_h

#include <pthread.h>
#include <stdint.h>

/*
	start == end代表为空
	至少保留一个空闲，表示满
*/
typedef struct {
	void *data;
	uint32_t capacity;
	uint32_t begin; // 写入后移动，总是指向第一个空闲位置
	uint32_t end;	// 读取或移动，总是指向第一个数据位置
	pthread_mutex_t mutex;
} circle_buffer;

circle_buffer *circle_buffer_create(uint32_t capacity);
circle_buffer *circle_buffer_destory(circle_buffer *circle_buffer);
int32_t circle_buffer_read(circle_buffer *circle_buffer, byte destination[],
						   uint32_t max_size);
int32_t circle_buffer_write(circle_buffer *circle_buffer, const byte source[],
							uint32_t size);

uint32_t circle_buffer_remain_data_size(const circle_buffer *circle_buffer);
uint32_t circle_buffer_remain_idle_space(const circle_buffer *circle_buffer);
void circle_buffer_display(const circle_buffer *circle_buffer);

#define circle_buffer_write_string(circle_buffer, string)                      \
	circle_buffer_write(circle_buffer, string, strlen(string) + 1)
// 如果最后是\0，顺势读出；如果不是，不读
#define circle_buffer_read_string(circle_buffer, destination, max_size)        \
	circle_buffer_read(circle_buffer, destination, max_size - 1)

#endif

#endif